package com.ruoyi.background.domain;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 站点题目对象 app_site_topic
 *
 * @author susu
 * @date 2024-08-27
 */
public class AppSiteTopic extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 站点的id
     */
    @Excel(name = "站点的id")
    private Long siteId;

    private String siteName;

    /**
     * 题目
     */
    @Excel(name = "题目")
    private String title;

    /**
     * 正确答案
     */
    @Excel(name = "正确答案")
    private String tanser;

    /**
     * 选项1
     */
    @Excel(name = "选项1")
    private String choose1;

    /**
     * 选项2
     */
    @Excel(name = "选项2")
    private String choose2;

    /**
     * 选项3
     */
    @Excel(name = "选项3")
    private String choose3;

    /**
     * 选项4
     */
    @Excel(name = "选项4")
    private String choose4;

    /**
     * 类型1单选2多选3判断
     */
    @Excel(name = "类型1单选2多选3判断")
    private Long topicType;

    /**
     * 题目顺序
     */
    @Excel(name = "题目顺序")
    private Long topicOrder;

    /**
     * 解析
     */
    @Excel(name = "解析")
    private String parse;


    private List<Object> chooseList;

    private Object userAnswer;

    private String userAnsWerString;

    private String typeName;

    private Integer isTrue;


    public Integer getIsTrue() {
        return isTrue;
    }

    public void setIsTrue(Integer isTrue) {
        this.isTrue = isTrue;
    }

    public String getUserAnsWerString() {
        return userAnsWerString;
    }

    public void setUserAnsWerString(String userAnsWerString) {
        this.userAnsWerString = userAnsWerString;
    }

    public void initTopic() {
//        this.tanser = "";
        this.chooseList = new ArrayList<>();
        if (!ObjectUtils.isEmpty(this.choose1)) {
            Map<String, String> map = new HashMap<>();
            map.put("label", this.choose1);
            map.put("name", "A");
            chooseList.add(map);
        }
        if (!ObjectUtils.isEmpty(this.choose2)) {
            Map<String, String> map = new HashMap<>();
            map.put("label", this.choose2);
            map.put("name", "B");
            chooseList.add(map);
        }
        if (!ObjectUtils.isEmpty(this.choose3)) {
            Map<String, String> map = new HashMap<>();
            map.put("label", this.choose3);
            map.put("name", "C");
            chooseList.add(map);
        }
        if (!ObjectUtils.isEmpty(this.choose4)) {
            Map<String, String> map = new HashMap<>();
            map.put("label", this.choose4);
            map.put("name", "D");
            chooseList.add(map);
        }
        if (this.topicType == 1 || this.topicType == 3) {
            this.userAnswer = "";
            this.typeName = this.topicType == 1 ? "单选题" : "判断题";
        } else if (this.topicType == 2) {
            this.typeName = "多选题";
            this.userAnswer = new ArrayList<>();
        }
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Object getUserAnswer() {
        return userAnswer;
    }

    public void setUserAnswer(Object userAnswer) {
        this.userAnswer = userAnswer;
    }

    public List<Object> getChooseList() {
        return chooseList;
    }

    public void setChooseList(List<Object> chooseList) {
        this.chooseList = chooseList;
    }

    public String getSiteName() {
        return siteName;
    }

    public void setSiteName(String siteName) {
        this.siteName = siteName;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setSiteId(Long siteId) {
        this.siteId = siteId;
    }

    public Long getSiteId() {
        return siteId;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTanser(String tanser) {
        this.tanser = tanser;
    }

    public String getTanser() {
        return tanser;
    }

    public void setChoose1(String choose1) {
        this.choose1 = choose1;
    }

    public String getChoose1() {
        return choose1;
    }

    public void setChoose2(String choose2) {
        this.choose2 = choose2;
    }

    public String getChoose2() {
        return choose2;
    }

    public void setChoose3(String choose3) {
        this.choose3 = choose3;
    }

    public String getChoose3() {
        return choose3;
    }

    public void setChoose4(String choose4) {
        this.choose4 = choose4;
    }

    public String getChoose4() {
        return choose4;
    }

    public void setTopicType(Long topicType) {
        this.topicType = topicType;
    }

    public Long getTopicType() {
        return topicType;
    }

    public void setTopicOrder(Long topicOrder) {
        this.topicOrder = topicOrder;
    }

    public Long getTopicOrder() {
        return topicOrder;
    }

    public void setParse(String parse) {
        this.parse = parse;
    }

    public String getParse() {
        return parse;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("siteId", getSiteId())
                .append("title", getTitle())
                .append("tanser", getTanser())
                .append("choose1", getChoose1())
                .append("choose2", getChoose2())
                .append("choose3", getChoose3())
                .append("choose4", getChoose4())
                .append("topicType", getTopicType())
                .append("topicOrder", getTopicOrder())
                .append("parse", getParse())
                .append("updateTime", getUpdateTime())
                .append("updateBy", getUpdateBy())
                .append("createTime", getCreateTime())
                .append("createBy", getCreateBy())
                .append("remark", getRemark())
                .toString();
    }
}
